package com.kehutong.applet.app;

import com.kehutong.applet.service.AdvertPositionService;
import com.kehutong.applet.service.AdvertService;
import com.kehutong.applet.service.AppletMenuService;
import com.kehutong.common.DoveClient;
import com.kehutong.common.Java8TimeUtils;
import com.kehutong.common.util.Token;
import org.coraframework.authz.HasPermission;
import org.coraframework.inject.Inject;
import org.coraframework.json.JSONObject;
import org.coraframework.logger.Logger;
import org.coraframework.logger.LoggerFactory;
import org.coraframework.mvc.MvcAction;
import org.coraframework.mvc.http.ReqMapping;
import org.coraframework.mvc.http.result.JSONResult;
import org.coraframework.mvc.http.result.Result;

/**
 * @program: kht
 * @description: 广告信息接口
 * @author: joneron
 * @create: 2021/5/27
 **/
@MvcAction
@ReqMapping("/kht-bin/applet/advert")
public class AdvertAction {

    private static final Logger logger = LoggerFactory.getLogger(AdvertAction.class);

    @Inject
    AdvertService advertService;

    @Inject
    AdvertPositionService advertPositionService;

    @Inject
    private DoveClient doveClient;

    @ReqMapping("/position")
    public JSONResult position(Token token, JSONObject jsonObject) {

        return Result.success(advertPositionService.findList(jsonObject));
    }

    @ReqMapping("/list")
    public JSONResult list(Token token,JSONObject jsonObject) {

        jsonObject.put("endTime", Java8TimeUtils.dateLong());
        return Result.success(advertService.findList(jsonObject));
    }

    @ReqMapping("/saveClick")
    public JSONResult saveClick(Token token,JSONObject jsonObject) {

        return Result.success(advertService.saveClickNum(jsonObject.getString("id")));
    }


}
